/**
 * 任务日志模型
 *
 * Created by snowingsea on 2020/03/04.
 */
const mongoose = require('mongoose');
const schemaDefinition = require('./schema/task-log');
const schemaInstance = mongoose.Schema(schemaDefinition);
schemaInstance.index({
  taskId: 1,
  ackNo: 1,
}, { unique: true });
const day = 24 * 3600;
schemaInstance.index({ createdAt: 1 }, { expireAfterSeconds: 15 * day });
const modelInstance = mongoose.model('message-log', schemaInstance);
// schemaInstance.set('autoIndex', false);
// mongoose.connection.on('open', () => modelInstance.syncIndexes().catch(() => {}));

/**
 * Export model definition object.
 */
module.exports = modelInstance;
